Skip to content

Fix #6229: @ConstructorProperties must not be gated by DETECT_PARAMETER_NAMES - #6230

Merged
cowtowncoder merged 7 commits into
FasterXML:3.xfrom
mauriciocsz:fix/constructor-properties-detect-parameter-names
Sep 25, 2026
Merged

cowtowncoder merged 7 commits into
FasterXML:3.xfrom
mauriciocsz:fix/constructor-properties-detect-parameter-names

Conversation

@mauriciocsz

@mauriciocsz mauriciocsz commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6229.

MapperFeature.DETECT_PARAMETER_NAMES (added in #5314) is meant to control only the bytecode-derived (-parameters) implicit parameter name detection that Jackson 3 merged in from the old jackson-parameter-names module. Per its own Javadoc, disabling it should "restore the older Jackson 2.x behavior" — but Jackson 2 always supported @ConstructorProperties independently of that module.

JacksonAnnotationIntrospector.findImplicitPropertyName() had a single early-return gated on DETECT_PARAMETER_NAMES sitting above both the @ConstructorProperties lookup and the bytecode lookup, so disabling the flag broke both instead of just the bytecode one.

This PR moves the DETECT_PARAMETER_NAMES check down so it only gates the bytecode-based fallback (_findImplicitName), leaving the @ConstructorProperties-based lookup (_javaBeansHelper.findConstructorName) unconditional, matching both the feature's documented intent and Jackson 2 parity.

Changes

  • src/main/java/tools/jackson/databind/introspect/JacksonAnnotationIntrospector.java: scoped the DETECT_PARAMETER_NAMES check to only the two bytecode-based branches (constructor parameter fallback, static factory-method parameter detection); @ConstructorProperties resolution no longer short-circuits. Extracted the check into a detectParamNames local (matches this codebase's existing convention for caching a MapperFeature check).
  • src/test/java/tools/jackson/databind/deser/WithoutParamNamesModule5314Test.java: extended the existing DETECT_PARAMETER_NAMES test file (rather than adding a new one) with CtorPropsBean178 — a bean matching Bean178's shape but with @ConstructorProperties added — and a new test, testConstructorPropertiesIgnoresDetectParameterNames, verifying it deserializes successfully under all three configs testWorksByDefault already exercises (enabled, disabled, Jackson2Defaults).

Testing

./mvnw test -Dtest=WithoutParamNamesModule5314Test

Both tests pass (1 pre-existing + 1 new). Locally reverted just the JacksonAnnotationIntrospector change (keeping the new test) to confirm the new test fails against pre-fix code with the exact InvalidDefinitionException from #6229 ("has no property name ... cannot use as property-based Creator"), then passes again with the fix restored.

No other tests were touched; the change is scoped to the one method.

MapperFeature.DETECT_PARAMETER_NAMES (added in FasterXML#5314) is meant to
control only the bytecode-derived (-parameters) implicit parameter
name detection merged into core in Jackson 3. JacksonAnnotationIntrospector
.findImplicitPropertyName() had a single early-return gated on that
flag sitting above both the @ConstructorProperties lookup and the
bytecode lookup, so disabling the flag silently broke
@ConstructorProperties-based Creator detection as well, even though
that mechanism predates and is independent of -parameters compilation
and worked regardless of it in Jackson 2.

Scopes the DETECT_PARAMETER_NAMES check to only the two bytecode-based
branches, leaving @ConstructorProperties resolution unconditional.
@cowtowncoder cowtowncoder added the cla-needed PR looks good (although may also require code review), but CLA needed from submitter label Sep 25, 2026
@github-actions

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 82.36% 📈 +0.020%
Branches branches 75.95% 📉 -0.040%

Coverage data generated from JaCoCo test results

@github-actions

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 82.34% 📈 +0.000%
Branches branches 76.00% 📈 +0.010%

Coverage data generated from JaCoCo test results

@mauriciocsz

Copy link
Copy Markdown
Contributor Author

@cowtowncoder Signed SLA sent! lmk if anything else is required

@cowtowncoder cowtowncoder added this to the 3.3.0 milestone Sep 25, 2026
@cowtowncoder cowtowncoder added cla-received PR already covered by CLA (optional label) and removed cla-needed PR looks good (although may also require code review), but CLA needed from submitter labels Sep 25, 2026
@github-actions

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 82.34% 📈 +0.000%
Branches branches 76.00% 📈 +0.010%

Coverage data generated from JaCoCo test results

@gitar-bot

gitar-bot Bot commented Sep 25, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Constructor-property creator detection now works regardless of bytecode-name detection settings.

Fixes @ConstructorProperties being incorrectly gated by DETECT_PARAMETER_NAMES by moving the feature check to only guard bytecode-based parameter detection, restoring Jackson 2 compatibility. The fix includes a new test verifying @ConstructorProperties works regardless of the parameter detection flag setting. No issues found.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@github-actions

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 82.34% 📈 +0.000%
Branches branches 76.00% 📈 +0.010%

Coverage data generated from JaCoCo test results

@cowtowncoder
cowtowncoder merged commit e7274f7 into FasterXML:3.x Sep 25, 2026
1 check passed
@cowtowncoder

Copy link
Copy Markdown
Member

Thank you, @mauriciocsz !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-received PR already covered by CLA (optional label)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MapperFeature.DETECT_PARAMETER_NAMES=false silently disables @ConstructorProperties-based Creator detection too

2 participants